package com.weixin.paleituo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.weixin.paleituo.R;
import com.weixin.paleituo.base.BaseRecycleAdapter;
import com.weixin.paleituo.bean.GoodsSpecifBean;
import com.weixin.paleituo.bean.OrderGoods;
import com.weixin.paleituo.help.RecycleViewHolder;
import com.weixin.paleituo.util.StringUtils;
import com.weixin.paleituo.util.UIUtils;

import java.text.DecimalFormat;
import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 商品清单列表查看
 * 这里只做展示效果，没有任何页面交互
 *
 * @author fengzhen
 * @version v1.0, 2018/4/1
 */
public class CustomGoodsListPreRecycleAdapter extends BaseRecycleAdapter<OrderGoods> {

    public CustomGoodsListPreRecycleAdapter(Context context, ArrayList<OrderGoods> datas) {
        super(context, datas, R.layout.item_custom_goods_list_pre);
    }

    @Override
    protected void setData(RecycleViewHolder holder, OrderGoods s, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        OrderGoods model = mDatas.get(position);
        Glide.with(mContext)
                .load(model.getListUrl())
                .into(viewHolder.mImgCustomGoodsItemGoodsListPre);
        viewHolder.mTvCustomNameItemGoodsListPre.setText(model.getGoodsName());
        viewHolder.mTvCountEachItemGoodsListPre.setText(String.format(mContext.getString(R.string.string_x), model.getCount()));
        viewHolder.mTvCustomContentActivityCreateOrder.setText(model.getMsg());
    }

    @Override
    public RecycleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(UIUtils.inflate(mContext, R.layout.item_custom_goods_list_pre, parent, false));
    }

    static class ViewHolder extends RecycleViewHolder {
        @BindView(R.id.img_custom_goods_item_goods_list_pre)
        ImageView mImgCustomGoodsItemGoodsListPre;
        @BindView(R.id.tv_custom_name_item_goods_list_pre)
        TextView mTvCustomNameItemGoodsListPre;
        @BindView(R.id.tv_custom_count_each_item_goods_list_pre)
        TextView mTvCountEachItemGoodsListPre;
        @BindView(R.id.tv_custom_content_activity_create_order)
        TextView mTvCustomContentActivityCreateOrder;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
